package net.lab1024.sa.admin.module.business.category.controller;

import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
import net.lab1024.sa.admin.module.business.category.domain.form.FrontCategoryAddForm;
import net.lab1024.sa.admin.module.business.category.domain.form.FrontCategoryQueryForm;
import net.lab1024.sa.admin.module.business.category.domain.form.FrontCategoryUpdateForm;
import net.lab1024.sa.admin.module.business.category.domain.vo.FrontCategoryVO;
import net.lab1024.sa.admin.module.business.category.service.FrontCategoryService;
import net.lab1024.sa.common.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.common.common.domain.ResponseDTO;
import net.lab1024.sa.common.common.domain.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;

/**
 * 前台类目 Controller
 *
 * @Author jabari
 * @Date 2023-06-01 15:12:18
 * @Copyright 51dev.cn
 */

@RestController
@Api(tags = AdminSwaggerTagConst.Business.MANAGER_CATEGORY)
public class FrontCategoryController {

    @Autowired
    private FrontCategoryService frontCategoryService;

    @ApiOperation("分页查询 @author jabari")
    @PostMapping("/frontCategory/queryPage")
    public ResponseDTO<PageResult<FrontCategoryVO>> queryPage(@RequestBody @Valid FrontCategoryQueryForm queryForm) {
        return ResponseDTO.ok(frontCategoryService.queryPage(queryForm));
    }

    @ApiOperation("添加 @author jabari")
    @PostMapping("/frontCategory/add")
    public ResponseDTO<String> add(@RequestBody @Valid FrontCategoryAddForm addForm) {
        return frontCategoryService.add(addForm);
    }

    @ApiOperation("更新 @author jabari")
    @PostMapping("/frontCategory/update")
    public ResponseDTO<String> update(@RequestBody @Valid FrontCategoryUpdateForm updateForm) {
        return frontCategoryService.update(updateForm);
    }

    @ApiOperation("批量删除 @author jabari")
    @PostMapping("/frontCategory/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return frontCategoryService.batchDelete(idList);
    }

    @ApiOperation("单个删除 @author jabari")
    @GetMapping("/frontCategory/delete/{frontCategoryId}")
    public ResponseDTO<String> batchDelete(@PathVariable Integer frontCategoryId) {
        return frontCategoryService.delete(frontCategoryId);
    }
}
